<?php
if(!defined('IN_KKFRAME')) exit();

$amount = DB::result_first("SELECT COUNT(*) FROM thread");
$max_page = ceil($amount / 10);
$page = max(1, min(intval($_GET['page']), $max_page));
$limit = 10*($page - 1);
$threadlist = array();
$threadlist = DB::fetch_all("SELECT * FROM thread ORDER BY lastpost DESC LIMIT {$limit},10");

include template('index');